<?php
/**
 * Description of cart
 * 
 * @author trangnguyen
 * @since Dec 30, 2013 - 4:26:23 PM
 */
/**
 * End of cart
 */
?>
<?php $this->pageTitle = Option::getItem('order') . ' - ' . Option::getItem('site_name'); ?>
<!---Đặt hàng-->

<script src="<?php echo $this->assetDir ?>/js/addtocart.js"></script> 
<div id="wrap-order">
    <?php $totalmoney = 0; ?>
    <?php if ($cartItems): ?>
        <div class="form-cart fl">
            <table class="table-cart">
                <tr class="row top">
                    <td>STT</td>
                    <td>Sản phẩm</td>
                    <td>Giá</td>
                    <td>Số lượng</td>
                    <td>Thành tiền</td>
                </tr> 
                <?php
                $i = 0;
                foreach ($cartItems as $item):
                    $i++;
                    ?>
                    <tr class="row list-row">
                        <td><?php echo $i; ?></td>
                        <td class="left order-pro">
                            <div class="fl cart-img">
                                <img src="<?php echo $item->product->publicImg ?>">
                            </div>
                            <div class="desc-cart fl">
                                <?php echo $item->product->name ?>
                                <div class="del-pro">
                                    <a
                                        title="<?php echo 'Xóa khỏi giỏ hàng'; ?>"
                                        href="<?php echo $this->createUrl('order/delItem', array('id' => $item->id)) ?>" 
                                        onclick="return confirm('<?php echo 'Bạn có chắc chắn muốn xóa sản phẩm này không?' ?>')">
                                        Xóa sản phẩm
                                    </a> 
                                </div>
                            </div>

                            <div class="clear"></div>
                        </td>
                        <td class="col-price">
                            <?php echo $item->product->priceFormat; ?>
                        </td>
                        <td>
                            <?php
                            echo CHtml::textField('qty', $item->qty, array(
                                'id' => $item->id,
                                'price' => $item->product->price,
                                'class' => 'sl'
                            ));
                            ?>
                        </td>
                        <?php $totalmoney+= $item->total_money; ?>
                        <td class="col-price total_money" money="<?php echo $item->total_money ?>">
                            <?php echo number_format($item->total_money, 0, ",", ".") . 'đ'; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </table>
        </div>
        <div id="total" class="fl">
            <table>
                <tr class="row">
                    <td class="col-price top">Tổng tiền: </td>
                    <td id="total_cart" class="money"><?php echo number_format($totalmoney, 0, ",", ".") . 'đ'; ?></td>
                </tr>

            </table>
            <div class="btn-payment">
                <a href="<?php echo Yii::app()->createUrl('order/payment') ?>">
                    Thanh toán &Gt;
                </a>
            </div>
        </div>
        <div class="clear"></div>
    <?php else: ?>
        <p class="error"> Hiện giỏ hàng của bạn đang trống</p>
    <?php endif; ?>
</div>